//% color="#5b3fe8" iconWidth=50 iconHeight=40
namespace json {
    //% block="get json[JSON] as JsonObject" blockType="command"
    //% JSON.shadow="string" JSON.defl=""
    export function getJson(parameter: any, block: any) {
        let json = parameter.JSON.code
        Generator.addInclude('json', '#include <ArduinoJson.h>');
        Generator.addObject(`jsonBuffer`, `DynamicJsonBuffer`, `jsonBuffer;`);
        Generator.addCode(`JsonObject& root = jsonBuffer.parseObject(${json});`);
    }

    // //% block="params Key[KEY]Value" blockType="reporter"
    //% KEY.shadow="string" KEY.defl="key"
    export function getValue(parameter: any, block: any) {
        let key = parameter.KEY.code
        Generator.addCode(`root[${key}].asString()`);
    }
	
}
